/**
 * Yolema.com Inc.
 * Copyright (c) 2011-2012 All Rights Reserved.
 */
package org.grayrabbit.pay.core.biz.manager.transaction.impl;

import org.grayrabbit.pay.core.biz.manager.transaction.TradeRecordHistoryManager;
import org.grayrabbit.pay.core.model.entity.transaction.TradeRecordHistory;
import org.grayrabbit.pay.core.model.enums.TradeEnum;
import org.grayrabbit.pay.core.model.pages.PageList;
import org.grayrabbit.pay.core.model.results.GenericsResult;
import org.grayrabbit.pay.core.model.results.PayResult;
import org.grayrabbit.pay.core.service.transaction.TradeRecordHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 
 * 
 * @author liyd
 * @version $Id: TradeRecordHistoryManagerImpl.java, v 0.1 Fri Jun 01 11:16:04 CST 2012 liyd Exp $
 */
@Component
public class TradeRecordHistoryManagerImpl implements TradeRecordHistoryManager {

    @Autowired
    private TradeRecordHistoryService tradeRecordHistoryService;

    /**
     * 查询业务列表
     * 
     * @param district
     * @return
     */
    public GenericsResult<PageList<TradeRecordHistory>> queryPageList(TradeRecordHistory tradeRecordHistory) {

        GenericsResult<PageList<TradeRecordHistory>> result = new GenericsResult<PageList<TradeRecordHistory>>(
            true);
        PageList<TradeRecordHistory> list = tradeRecordHistoryService
            .queryPageList(tradeRecordHistory);
        for (TradeRecordHistory atrade : list) {
            atrade.setStatusEnum(TradeEnum.getTradeEnum(atrade.getOrderStatus()));
        }
        result.setResultData(list);

        return result;
    }

    /**
     * 根据Id得到实体对象
     * 
     * @param id
     * @return
     */
    public GenericsResult<TradeRecordHistory> getById(Long id) {

        GenericsResult<TradeRecordHistory> result = new GenericsResult<TradeRecordHistory>(true);

        result.setResultData(tradeRecordHistoryService.getById(id));

        return result;

    }

    /**
     * 根据id批量删除
     * 
     * @param idArray
     * @return
     */
    public PayResult deleteBatchById(Long[] idArray) {

        PayResult result = new PayResult(true);

        tradeRecordHistoryService.deleteBatchById(idArray);

        return result;
    }

    /**
     * 添加一个对象
     * 
     * @param tradeRecordHistory
     * @return
     */
    public GenericsResult<TradeRecordHistory> insert(TradeRecordHistory tradeRecordHistory) {

        GenericsResult<TradeRecordHistory> result = new GenericsResult<TradeRecordHistory>(true);

        tradeRecordHistoryService.insert(tradeRecordHistory);

        return result;

    }

    /**
     * 更新一个对象
     * 
     * @param tradeRecordHistory
     * @return
     */
    public GenericsResult<Integer> update(TradeRecordHistory tradeRecordHistory) {

        GenericsResult<Integer> result = new GenericsResult<Integer>(true);

        result.setResultData(tradeRecordHistoryService.update(tradeRecordHistory));

        return result;
    }

    /**
     * 删除一个对象
     * 
     * @param tradeRecordHistory
     * @return 
     */
    public PayResult delete(TradeRecordHistory tradeRecordHistory) {

        PayResult result = new PayResult(true);

        tradeRecordHistoryService.delete(tradeRecordHistory);

        return result;
    }

}
